<template>
  <div class="line2"></div>
</template>

<script>
import * as echarts from 'echarts'
export default {
  data () {
    return {

    }
  },
  methods: {
    lines () {
      const line2 = echarts.init(document.querySelector('.line2'))
      const option = {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        },
        legend: {

        },
        backgroundColor: '#020347',
        xAxis: {
          type: 'category',
          data: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18']
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            type: 'line',
            name: 'A',
            data: ['0', '1', '0.8', '0.4', '0'],
            // 平滑开启
            smooth: true,
            // 区域样式
            areaStyle: {
              color: {
                type: 'linear',
                x: 0,
                y: 0,
                x2: 1,
                y2: 1,
                colorStops: [{
                  offset: 0, color: 'purple' // 0% 处的颜色
                }, {
                  offset: 1, color: 'pink' // 100% 处的颜色
                }]
              }
            }
          },
          {
            type: 'line',
            name: 'B',
            data: ['0', '0', '0.3', '0.4', '0.4', '0.7', '0'],

            smooth: true,
            areaStyle: {
              color: {
                type: 'linear',
                x: 0,
                y: 0,
                x2: 1,
                y2: 1,
                colorStops: [{
                  offset: 0, color: 'skyblue' // 0% 处的颜色
                }, {
                  offset: 1, color: 'black' // 100% 处的颜色
                }]
              }
            }
          }

        ]
      }
      line2.setOption(option)
    }
  },
  mounted () {
    this.lines()
  }
}
</script>

<style>
.line2{
width: 690px;
height: 400px;
margin-left: 20px;
background-color: #fff;
}
</style>
